var t = require("./api"), a = getApp();

Component({
    properties: {},
    data: {
        activeIndex: "",
        showCardResult: !1,
        imgCount: [ {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        } ],
        imgCount_lottery: [ {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/face.png"
        } ],
        imgCount_back: [ {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/back.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/back.png"
        }, {
            imgSrc: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/back.png"
        } ],
        bingoImg: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/bingo.png",
        wingsLightImg: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/wingsLight.png",
        lightSpotImg: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/lightSpot.png",
        btnImg: "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/btn.png",
        lotteryResults: {},
        lotteryLock: !1
    },
    methods: {
        clickCard: function(e) {
            var c = this;
            a.kta.clickStat("027d2110aa6c40178a160b4ae3139956"), this.data.lotteryLock || (this.setData({
                lotteryLock: !0
            }), (0, t.dolottery)().then(function(t) {
                var a = t.message;
                if ("0" == t.code) {
                    var e = t.data;
                    c.setData({
                        lotteryResults: e
                    });
                } else console.warn(a);
            }).finally(function() {
                c.changeCard(e);
            }));
        },
        changeCard: function(t) {
            var a = t.currentTarget.dataset.index;
            this.data.showCardResult || (this.setData({
                showCardResult: !1,
                activeIndex: a
            }), this.changeLotteryImg());
        },
        changeLotteryImg: function() {
            for (var t = this.data.imgCount_lottery, a = 0; a < t.length; a++) {
                var e = this.returnCardType(a);
                t[a].imgSrc = "https://txwk.10010.com/miniprogram_kcard/chargeSucceedLottery/".concat(e, ".png");
            }
            this.setData({
                imgCount_lottery: t
            });
        },
        returnCardType: function(t) {
            var a = this.data, e = a.activeIndex, c = a.showCardResult;
            return t !== e && c && (0 === t || 1 === t && 0 === e) ? "face_left" : t !== e && c && (2 === t || 1 === t && 2 === e) ? "face_right" : "face";
        },
        animationEnd: function() {
            this.setData({
                showCardResult: !0
            }), this.changeLotteryImg();
        },
        luckJump: function() {
            a.kta.clickStat("a0980d5c894f41e9816cede97a3fe65f");
            var t = this.data.lotteryResults, e = t.path, c = t.appid;
            t.type;
            c = c || "wxc47d9eb33eec8b6a", e = e || "/pages/YQYL_homePage/index?channel=01-0379-a5ar-a66a&adtag=01-0379-a5ar-a66a", 
            wx.navigateTo({
                url: e,
                success: function() {
                    console.log("成功打开小程序appid：", c, ";path：", e);
                },
                fail: function(t) {
                    console.warn(t);
                }
            });
        }
    },
    created: function() {},
    attached: function() {},
    ready: function() {},
    moved: function() {},
    detached: function() {}
});